-
Notifications
You must be signed in to change notification settings - Fork 16
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
Need a way to specify a server otel config independently of app otel config #169
Comments
It seems to me that option 1 may be the only viable option. Option 2 would add a lot of complexity to MP Config, so may not be a good idea. Option 3 is rather limited in that it requires server-level attributes to not overlap with app-level attributes (since the server-level attributes in environment variables would take precedence over the app-level attributes in microprofile-config.properties). |
Brought up the question of what the right approach is for handling logs/traces/metrics in case where you have multiple apps and server producing telemetry. from April 4, 2024 OpenTelemetry Java + Instrumentation SIG minutes: [don] question on best usage of openTelemetry instances and resource attributes for app servers running multiple apps
Comments from the call suggest that having separate OTel sdk instances is the right approach for this, and that the resource attributes mentioned above look as people would expect. Comments also indicated that the monitoring tools very likely don't handle this situation in an elegant way, nor with any consistency. They also said this is an issue that is coming up from others as well. related to this, there is a new OTel SIG which started last week - see https://github.com/open-telemetry/community/blob/main/projects/resources-and-entities.md#problem-1-commingling-of-entities |
The above comment has 2 somewhat contradictory points:
Here are a few options to consider: Option A Option B Option C |
I'm leaning towards Option A. I expect most of the time the best answer for users will be to use one OTel instance for the whole server, so we might want to consider making |
+1. It is a best practice for the deployment of having one app per server. However, this spec needs to define the behavior of what behaviour is for multiple apps per server when defining single_instance to be |
I was briefly considering other options such as "inheriting" server span processors or having server export metrics to all application sdks. But in the end that either hits the closed-for-extension design of OpenTelemetry SDK or lead to duplicate measurements. Until OpenTelemetry has a solution for "less global" Resource definition, I think I'm leaning towards variant of Option A, but I think we can make it work without explicit properties:
I will not be able to join the call today, so we may discuss it further next week. |
@pdudits ,
I think we would want people to still use MP Config to configure this, regardless of whether they are using a global instance or app-specific instances ("vendor specific means" sounds inconsistent with that goal). If we do want everything to be configurable by MP Config, then that motivates needing Are you thinking that we could have |
IIUC Patrik has made a careful distinction that I was also wondering about. There seem to be two goals:
What Patrik has describes seems reasonable for multi-app implementations. We also have two categories of MP implementations to consider: those which do support multiple apps and those which do not. Is goal 1 something we would want for single-application implementations (as well as multi-app implementations)? That is, allow the emitted signals to indicate whether they are from the server or the application? Is goal 2 also valid for single-app implementations? That is, are we mandating that all implementations would permit configuring the server OTel SDK differently from the application OTel SDK? Or, is one or both of these goals optional parts of the spec which multi-app vendors would satisfy but single-app vendors need not? |
The reason I wouldn't want to standardize server-wide Config attributes is because then we need to specify what happens when two or more applications deployed into the runtime define these. Also -- at least in case of Payara -- runtime starts sooner than an application-level properties is discovered, requiring re-initialization of server SDK. Relying on global values instead gives better defaults -- heterogenous environments would define OTEL endpoints via environment variables anyway (I suppose), naturally contributing to both global and any overriden SDKs. |
It would be a wrong design if MP Config differentiates the server and app, All configuration are the same. |
I was thinking we'd only use
I don't believe the Instrumentation Scope Name is the right place to specify the application name. The instrumentation scope name may be used by open source components or instrumentation libraries when they get Tracers / Meters / Loggers, and those open source components and instrumentation libraries may be used with more than one app running in the same server. I was thinking the In order for the above to work, I think we'd end up with something like this... App server that can run multiple apps at same time
Runtime that can only run one app
|
@Emily-Jiang , in your comment... #169 (comment) were you objecting to the suggestion of having some attributes configured with MP Config and some through other means, or were you objecting to having some attributes ( |
I agree, but this issue started with premise that using different resource attributes within single SDK is an known unsolved design issue with Otel Sdk. I am therefore searching for solution that would allow using single SDK instance on multi-app server for better monitoring consistency and ease of configuration, while still being able to distuguish traces and metrics of individual applications. So first option is to use separate Sdk instances with different resource attributes, ultimately leading to separation of server and application metrics among different Otel resources and more runtime overhead, but emitting signals with perfect structure. Instrumentation scope our is our second best option. Spec already discourages use of arbitrary scopes, so we may as well use it for our purposes. All signals belong to single resource and instrumentation scopes may be used to slice across applications. Third option is to standardize signal attribute such as
I'd argue that using unprefixed properties (also) for global instance gives more consistency with single-use case, especially if we consider multi-app use to be the less relevant one. App server that can run multiple apps at same time
If global config mechanisms are used for configuring Otel endpoints -- and I would expect them to be used much more than app configurations -- then all three cases are configured the same way. And spec only needs to describe behavior of multi-app runtimes with minimal configuration versus a more complex one. |
One restriction of using shared SDK instance that didn't get mentioned yet is that any autoconfiguration service providers that application would ship with will not be enabled. |
Thanks for clarifying on the instrumentation scope. I think I now get what you're trying to do, avoiding having multiple openTelemetry instances to avoid the problem correlating data between them on the monitoring tool side. That said, I'm not sure how we would get instrumentation scope to always be the app name, since instrumentation libraries won't use that and we can only encourage customers to use it for their own meters / tracers, and since it would need to match the value we use when we get the loggers on the apps behalf.
The property file config source has a lower ordinal than the env var config source. So the env var values override the property file values and that means you couldn't have the same property specified by 2 different apps (in property files) and at the global level for the server (since the global value would override the 2 app values). |
Ah, right. So that would be the usecase for Another way to avoid prefix would then be to use different property file for app, such as
That's what we would do for injected tracers and meters (and any logging integration we might do). As far as I'm aware, the only instrumentation libraries out there are agents, and I remember us discussing that they will have hard time making them behave according to spec anyway. But also I'm suggesting that as optional feature anyway. |
I like the goal of having consistent config style for any server that is running just one app. How about this...? App server running one app / Runtime that can only run one app
App server running multiple apps
|
Yes, this proposal sounds good. |
update.... the approach below won't work as the attributes from microprofile-config.properties file will be hidden by any env variables set with the same name. new approachIn the MP Telemetry community call today @Emily-Jiang raised that we need to keep during server-level otel-instance initialization:
during app-level otel-instance initialization:
|
I think we have contradictory requirements. we want the server to use So if the most important requirement is backward compatibility (apps can set If the most important requirement is that servers running single apps can use |
The bottom line of the design is that the property should not change behaviors in single app vs. multiple app scenarios. |
IMO, it's more important that we avoid breaking backward compatibility with the previous release, so I'd like to propose that we stick with
Comments? |
My concern with with #169 (comment) is the usability for servers running a single app. We discussed this on today's call and I understand that this is the revised proposal Optional
Handling Global MP Config Sources:
Application-Level Config Sources:
The terms "initialize" and "provide" are used here to allow for the possibility of a shared central SDK with applications, though this detail is not required in the specification. I'm also trying to not use word server in the description, because the spec usually says "runtime". Therefore if user has no concerns with multiple applications or require different settings they can happily use just |
@pdudits Nicely done. This (to me) clearly captures the discussion from the meeting. Let's not lose sight of the fact that, while important to some MP implementations and user communities, the multi-app support is an optional component of the spec. We need to make sure that the use case the spec mandates--single-app behavior without requiring an explicit deployment step--is simple and clear to users. In Patrik's description above I believe it is. Also, thanks to Patrik for noting that all this employs normal MP config mechanisms. Users in situations with multiple apps or with a single app that has an app-level |
Separate but related question... In MP in general, what principles guide whether something becomes an optional part of a spec vs. an implementation suggestion if vendors have chosen a particular approach? In MP metrics, for example, there are both. There are suggestions if a vendor chose to implement using Micrometer, but there are no TCK tests for those suggestions. On the other hand, the REST request metrics are optional; a vendor need not implement them but the behavior is specified and there are optional TCK tests to verify that behavior. In which category does this multi-app OTel config behavior properly belong? |
@pdudits , I think this makes sense. I looked at your comment from perspective of what properties we would need to consider at server startup time and at app startup time. One nuance that isn't called out is that we normally want there to only be one SDK instance created at the server level and shared with the app in the case where there is only 1 app. For that, during app startup, I think we need to check if there exists a server SDK instance, and if so, to share that if mp.server.otel.disabled is unset and otel.disabled=false. I've actually gone through all of the cases below to try to determine how things should be handled at server and app startup time with respect to creating SDK instances. This may seem like overkill, but it helps uncover edge cases like the one I mentioned in the previous paragraph, and hopefully eliminates any ambiguity. Server init time (can't see microprofile-config.properties config source)At server init time we need to consider the 9 possible combos resulting from the permutations of:
runtime initializes the central SDK using noop. effect is that no runtime-level signals are emitted for the following combinations
runtime initializes the central SDK using properties prefixed with mp.server.otel for the following combinations
runtime initializes the central SDK using properties prefixed with otel for the following combinations
App init time (can see all config sources)note, server_sdk_enabled is not meant to be a config property -- it is just a detection we need to do to see if there was a non-noop SDK created at server init time. At app init time we need to consider the 18 possible combos resulting from the permuations of:
app shares central SDK with server for this app's signals for the following combinations
runtime provides an SDK for this app's signals using properties prefixed with otel for the following combinations
runtime provides a noop SDK for this app's signals for the following combinations
Does this all make sense and seem accurate? |
Thank you @pdudits @donbourne for the writeup! I have the following comments:
|
(1) -- I agree, any properties that will be paid attention to during server init (mp.server.otel.* or otel.*) have to be defined using env vars or system properties. (2) -- I agree that mp.server.otel.* config properties should work exactly same in multi-app as single-app if the user configures them. I think the "optional-ness" is just that typically user of a single-app runtime wouldn't set any mp.server.otel.* properties. I'm not sure if that's how @pdudits meant it though. |
I think this is clear and would be implementable. Thank you both for the write up! |
There are more conditions when the server SDK cannot be shared -- if application provides any
What I meant by optional was exactly what @donbourne says -- it is not required to specify the property for telemetry to work. But on the other hand the applications would behave exactly the same regardless of whether runtime would support |
Attempting to summarize the configuration story, from end user perspective:
(1) is the recommended configuration approach. |
Nice, Don. Clear and concise. I do have a couple concerns and a proposal that builds on Don's. And thanks for your patience; this note is not so concise! Concern 1When using runtimes that support one app, users should be able to employ any config source-- In such environments there is, as described by the MP Config spec, a single configuration applied to the entire JVM which contains both the runtime and the app. The system derives the single config from the available config sources as prescribed by MP Config. Users are accustomed to configuring the environment as a whole, regardless of which config sources they employ. If the MP Telemetry spec were to specify special treatment to a particular config source--env vars--for a certain group of settings then that would be quite a break from the conceptual model from MP config which users are accustomed to. Concern 2In the multi-app server case, should the MP Telemetry spec really restrict the source of truth for runtime-level behavior in multi-app servers to just env vars? What about the other config sources: system properties in particular but perhaps also custom config sources or even a It does seem a bit odd, given that we have MP Config, for MP Telemetry to propose a different regime for specifying config for this one portion of its behavior. Having said that, I absolutely get that servers that support multiple apps might apply various specific config sources at different times--some at runtime start-up, some at application deployment and start-up. But ideally a MicroProfile spec will not dictate those choices/restrictions. The proposalWhatever the exact behavior is for a given multi-app server, presumably the server's documentation explains that behavior so users of that implementation know what to expect and how to use config appropriately. Given that, I think the MP Telemetry spec could reasonably state something like this:
(or words to that effect which might have to change if my assumptions about multi-app server config behavior are wrong) The net effect might very well be the same as what Don's concise list describes. But this way the MP Telemetry spec itself does not impose any restrictions, non-standard config behavior, or implementation requirements on servers. Instead, it relies on MP-standard technology (config) plus whatever documented behavior individual servers have chosen to adopt. |
Previously, when I was referring to @tjquinno , I like your suggested wording. I'd tweak a couple of things...
|
Since we specify the mp.runtime.otel.* as environment variable or system properties, should we use MP_RUNTIME_OTEL_* to ensure they can be easily specified as environment variables as some OS does not allow dot for sure? The recommended approach is to use _ and uppercase. In this case, it is neater differentiation with app level properties. |
I think we should state system property: Would it be an issue if a user inconsistently sets the environment variable and system property? Does the system property take priority over the environment variables? |
Can you find out from OTEL config to see which one takes priority? My previous comment means there is no priority concerns by just using one config property. Personally, I think introducing two properties causes confusion. I would just stick to one as you can set |
The system properties have higher priority than envrionment variables. See docs for configuring-the-agent and specifying resource information via an environment variable. This is the same beahviour from MicroProfile Config. |
Okay, thanks @yasmin-aumeeruddy ! Thought further your suggestions and took back what I said with one property name. Let's go with what you suggested specifying |
Re: Don's follow-up Your edits to my suggested wording look good to me. Thanks for the upgrade. Re: Yasmin and Emily's discussion of env. vars and properties If the spec describes retrieving these settings using MP Config (as I suggested and as in Don's edit) then does the MP Telemetry spec really need to go into the details of environment variable and property formatting and ordering? The Telemetry spec could refer the reader to the MP Config spec which covers those aspects in detail. (It's indeed fortunate that OTel and MP Config order env. vars and properties the same way. Less confusion for our users.) |
@tjquinno these properties won't be discovered by MP Config as these would be used before the app has started. MP Config is not available to help out. |
What you say is true only of servers that support multiple applications and only because of implementation choices made as those servers were written. Those choices might well be very sensible ones, but they are choices nonetheless. For example, Helidon MP took a different approach. The Helidon-provided runtime code and the developer-provided app code are bundled as a single executable server JAR (plus dependencies). Helidon MP, and Helidon MP users, have embraced MP Config as the way of providing settings which control the behavior of the server as a whole, at the runtime level and at the application level. Both approaches--and potentially many others--are valid and comply with the MicroProfile specs. That said, no MP spec should include restrictions or requirements based on any single implementation approach. In particular, the MP Telemetry spec should not mandate that runtime-level settings can only be made using environment variable or system properties because that interferes with the Helidon approach (and perhaps others). Neither should the spec require that runtime settings be made in If we need to revise the phrasing of the text Don and I suggested I'm sure we can do that. But we need to find a way of describing the required behavior without tying that behavior to how a particular implementation approach works. Specifically, whatever the MP Telemetry spec text turns out to be, it needs to allow Helidon users to use MP config for all settings and Liberty users to use env. vars and system properties for runtime settings. |
I guess I typed too fast. I was talking about the implementation details. These properties are environment variables or system properties and they would be discovered by apps when apps are up for sure and they can be used by apps. What I meant is that when pushing out server metrics and logs at that time apps are not up, the server internals would have to query the variable values via System rather than MP Config. |
@pdudits , on your earlier comment...
... to generalize, I'd say we need to avoid sharing an otel sdk instance any time the properties used to create the server instance don't match the properties visible when requesting an app instance. That implies that impls will need to store the properties used to create the server instance for purpose of later comparison. |
for people using above rules for their impl, we've noticed that these rows can't occur... app shares central SDK with server for this app's signals for the following combinations
|
runtime level configs: mp.runtime.otel.sdk.disabled, |
I noticed a way to simplify a little bit -- whenever an app's otel settings are configured the same as the runtime's, the app will share the runtime's otel sdk instance rather than creating a new one. The configuration logic then becomes: when runtime starts:
when app starts:
I'm planning to open a PR for this issue shortly to update the spec. |
I've been trying to resolve a lot of issues with this configuration and have come to a new approach that I believe is far simpler and easier to implement, and I believe addresses the issues raised so far in this issue. Here's what I'm proposing... In order to enable any aspects of integration, the configuration If the If the At runtime initization time runtimes may use the At application initialization time runtime MUST use configuration sources available via MicroProfile Config for configuration. A few things to notice:
please let me know what you think. PR on its way :-) |
For servers that have the ability to run more than one app we currently have the ability to specify the otel config for each app separately using
microprofile-config.properties
files.In MP Telemetry 2.0, when we add logs and metrics, we'll need the server to be a first class provider of otel data as well. For example, logs emitted during server startup do not relate to any app, and many of the metrics (eg. JVM metrics) do not relate to any app.
As the server starts it needs to create its own otel instance so that metrics and logs have somewhere to go.
The problem is, MP Config doesn't let us specify different config attribute values for the server and for apps using the same config property names.
A few solution options to consider:
mp.server.otel.disabled
,mp.server.otel.traces.exporter
, etc.otel.service.name
note that for (1) we can't use config attributes that start with
otel
per https://opentelemetry.io/docs/specs/semconv/general/attribute-naming/#otel-namespaceThe text was updated successfully, but these errors were encountered: