Ejemplo n.º 1
0
    def __init__(
        self,
        events_table: ReadableStorage,
        events_ro_table: ReadableStorage,
        abstract_events_columns: ColumnSet,
        transactions_table: ReadableStorage,
        abstract_transactions_columns: ColumnSet,
    ) -> None:
        self.__events_table = events_table
        self.__events_ro_table = events_ro_table
        # Columns from the abstract model that map to storage columns present only
        # in the Events table
        self.__abstract_events_columns = abstract_events_columns
        self.__transactions_table = transactions_table
        # Columns from the abstract model that map to storage columns present only
        # in the Transactions table
        self.__abstract_transactions_columns = abstract_transactions_columns

        self.__event_translator = event_translator.concat(
            TranslationMappers(
                columns=[
                    ColumnToMapping(None, "release", None, "tags", "sentry:release"),
                    ColumnToMapping(None, "dist", None, "tags", "sentry:dist"),
                    ColumnToMapping(None, "user", None, "tags", "sentry:user"),
                    DefaultNoneColumnMapper(self.__abstract_transactions_columns),
                ],
                subscriptables=[DefaultNoneSubscriptMapper({"measurements"})],
            )
        )

        self.__transaction_translator = transaction_translator.concat(
            TranslationMappers(
                columns=[
                    ColumnToLiteral(None, "group_id", 0),
                    DefaultNoneColumnMapper(self.__abstract_events_columns),
                ]
            )
        )
Ejemplo n.º 2
0
            ("exclusive_time_32", Float(32)),
        ]),
    ),
])

events_translation_mappers = TranslationMappers(
    columns=[DefaultNoneColumnMapper(TRANSACTIONS_COLUMNS)],
    functions=[DefaultNoneFunctionMapper({"apdex", "failure_rate"})],
    subscriptables=[
        DefaultNoneSubscriptMapper({"measurements", "span_op_breakdowns"})
    ],
)

transaction_translation_mappers = TranslationMappers(
    columns=[
        ColumnToLiteral(None, "group_id", 0),
        DefaultNoneColumnMapper(EVENTS_COLUMNS),
    ],
    functions=[DefaultNoneFunctionMapper({"isHandled", "notHandled"})],
)

null_function_translation_mappers = TranslationMappers(
    curried_functions=[DefaultIfNullCurriedFunctionMapper()],
    functions=[DefaultIfNullFunctionMapper()],
)


class DiscoverEntity(Entity):
    """
    Entity that represents both errors and transactions. This is currently backed
    by the events storage but will eventually be switched to use use the merge table storage.
Ejemplo n.º 3
0
                 None, "IPv4NumToString", (Column(None, None, "ip_address_v4"),),
             ),
             FunctionCall(
                 None, "IPv6NumToString", (Column(None, None, "ip_address_v6"),),
             ),
         ),
     ),
     ColumnToFunction(
         None, "user", "nullIf", (Column(None, None, "user"), Literal(None, ""))
     ),
     # These column aliases originally existed in the ``discover`` dataset,
     # but now live here to maintain compatibility between the composite
     # ``discover`` dataset and the standalone ``transaction`` dataset. In
     # the future, these aliases should be defined on the Transaction entity
     # instead of the dataset.
     ColumnToLiteral(None, "type", "transaction"),
     ColumnToColumn(None, "timestamp", None, "finish_ts"),
     ColumnToColumn(None, "username", None, "user_name"),
     ColumnToColumn(None, "email", None, "user_email"),
     ColumnToColumn(None, "transaction", None, "transaction_name"),
     ColumnToColumn(None, "message", None, "transaction_name"),
     ColumnToColumn(None, "title", None, "transaction_name"),
     ColumnToMapping(None, "geo_country_code", None, "contexts", "geo.country_code"),
     ColumnToMapping(None, "geo_region", None, "contexts", "geo.region"),
     ColumnToMapping(None, "geo_city", None, "contexts", "geo.city"),
 ],
 subscriptables=[
     SubscriptableMapper(None, "tags", None, "tags"),
     SubscriptableMapper(None, "contexts", None, "contexts"),
     SubscriptableMapper(None, "measurements", None, "measurements", nullable=True),
 ],
Ejemplo n.º 4
0
def test_column_literal_translation() -> None:
    assert ColumnToLiteral("table", "col", "my_literal").attempt_map(
        Column("c_alias", "table", "col"),
        SnubaClickhouseMappingTranslator(TranslationMappers()),
    ) == Literal("c_alias", "my_literal")