-
Couldn't load subscription status.
- Fork 2
Add collector endpoint and implement logging support #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The logic to stop the agent was found in the `Client` class. Move that to the `Agent` class instead. This will allow us to noop it out when the agent is not in use.
Add a configuration option that allows for a collector endpoint to be provided. When given, AppSignal for Python will not use the agent binary that is bundled with it, and instead send data to the given collector endpoint. Implement this by defining a `Binary` base class, and swapping the AppSignal's client `Agent` with a `NoopBinary` when the collector endpoint configuration option is set. This paves the way for defining a `Collector` class later on.
Configure the OpenTelemetry resource attributes to provide the required attributes for the collector to process the data. Add a new `service_name` configuration option to provide the service name that the collector expects. Since `revision` is optional, set a placeholder value when it is not present. Do the same for `service_name`.
When the collector is used, configure the OpenTelemetry logging SDK. Add an instrumentation that adds OpenTelemetry's `LoggingHandler` to the root logger in Python's built-in `logging` module. This will automatically send logs to AppSignal from any loggers that are not explicitly configured not to propagate to the root logger. Configure AppSignal's internal logger not to propagate to the root logger.
|
✔️ All good! |
7c79c66 to
643da00
Compare
The convention of using package names made sense as long as what we were enabling or disabling mapped cleanly to them. In the `logging` case, we're enabling instrumentation for the `logging` package, but this instrumentation lives in the `opentelemetry.sdk._logs` package. Using that package name, however, is confusing, as someone familiar with the SDK would think that we're disabling the logs section of the OpenTelemetry SDK entirely. Change the default instrumentation names to be the names of the libraries that they instrument, rather than the module paths of the modules in which the instrumentations are added. This also makes them shorter, which I'm sure is nice if you need to specify a couple of them. For backwards compatibility, support the name being specified with an `opentelemetry.instrumentation.` prefix, which is ignored when matching the names.
643da00 to
a9d45a5
Compare
This comment has been minimized.
This comment has been minimized.
| @pytest.fixture(scope="function", autouse=True) | ||
| def reset_agent_active_state() -> Any: | ||
| agent.active = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to reset this anymore between tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not! There's not an agent global anymore -- instead, each client has its own agent instance. We do reset the global client between tests, so the new one that is initialised should be in a clean state.
|
@unflxw can you ask this customer to try this change once it's released? |
This comment has been minimized.
This comment has been minimized.
|
FYI: Keeping this PR open because I keep finding small things here and there that need improving, as I go through documenting it. |
This is a message from the daily scheduled checks. |
375c8e1 to
d3a06a9
Compare
Implement the following configuration options in the integration, mapping to the collector-supported, `appsignal.config.`-prefixed resource attribute of the same name: - `filter_attributes` - `filter_function_parameters` - `filter_request_query_parameters` - `filter_request_payload` - `response_headers` - `send_function_parameters` - `send_request_query_parameters` - `send_request_payload` Additionally, also map the following existing configuration options in the integrations to resource attributes in the same manner: - `filter_session_data` (mapped to `filter_request_session_data`) - `ignore_actions` - `ignore_errors` - `ignore_namespaces` - `request_headers` - `send_session_data` (mapped to `send_request_session_data`) When validating the configuration, if the configuration would trigger the use of the collector, emit a warning about any configuration options set to non-default values which have no effect when using the collector. Do the same when the agent would be used for configuration options that would have no effect when using the agent.
d3a06a9 to
c7ac2bd
Compare
Prevent OpenTelemetry logs from being captured by the logging instrumentation and sent to AppSignal. Only disable the propagation of AppSignal logs to the root logger when the logging instrumentation is in use.
See appsignal/test-setups#341 for a test setup.
Part of #8, https://github.com/appsignal/appsignal-collector/issues/315
Move agent stop to
AgentclassThe logic to stop the agent was found in the
Clientclass. Movethat to the
Agentclass instead. This will allow us to noop it outwhen the agent is not in use.
Add
collector_endpointconfig optionAdd a configuration option that allows for a collector endpoint to
be provided. When given, AppSignal for Python will not use the agent
binary that is bundled with it, and instead send data to the given
collector endpoint.
Implement this by defining a
Binarybase class, and swapping theAppSignal's client
Agentwith aNoopBinarywhen the collectorendpoint configuration option is set. This paves the way for defining
a
Collectorclass later on.Configure OpenTelemetry for collector
Configure the OpenTelemetry resource attributes to provide the
required attributes for the collector to process the data.
Add a new
service_nameconfiguration option to provide the servicename that the collector expects.
Since
revisionis optional, set a placeholder value when it is notpresent. Do the same for
service_name.Instrument logging when using the collector
When the collector is used, configure the OpenTelemetry logging SDK.
Add an instrumentation that adds OpenTelemetry's
LoggingHandlerto the root logger in Python's built-in
loggingmodule. This willautomatically send logs to AppSignal from any loggers that are not
explicitly configured not to propagate to the root logger.
Configure AppSignal's internal logger not to propagate to the root
logger.
Simplify default instrumentation names
The convention of using package names made sense as long as what we
were enabling or disabling mapped cleanly to them. In the
loggingcase, we're enabling instrumentation for the
loggingpackage, butthis instrumentation lives in the
opentelemetry.sdk._logspackage.Using that package name, however, is confusing, as someone familiar
with the SDK would think that we're disabling the logs section of the
OpenTelemetry SDK entirely.
Change the default instrumentation names to be the names of the
libraries that they instrument, rather than the module paths of the
modules in which the instrumentations are added. This also makes them
shorter, which I'm sure is nice if you need to specify a couple of
them.
For backwards compatibility, support the name being specified with
an
opentelemetry.instrumentation.prefix, which is ignored whenmatching the names.