opentelemetry-operations-python icon indicating copy to clipboard operation
opentelemetry-operations-python copied to clipboard

Dependency issue on opentelemetry-exporter-gcp-monitoring

Open euri10 opened this issue 3 years ago • 11 comments

I have this in myy pyproject.toml and I'd like to upgrade

opentelemetry-instrumentation-fastapi = "0.17b0"
opentelemetry-instrumentation-asyncpg = "0.17b0"
opentelemetry-exporter-google-cloud = "0.17b0"

So it seems like opentelemetry-exporter-google-cloud was split in several new packages.

So I :

  1. poetry remove opentelemetry-exporter-google-cloud opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-asyncpg
  2. then I poetry add opentelemetry-exporter-gcp-trace opentelemetry-exporter-gcp-monitoring which works fine.
  3. finally as soon as I try to add poetry add opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-asyncpg I face this error:
❯ poetry add opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-asyncpg
Using version ^0.23b2 for opentelemetry-instrumentation-fastapi
Using version ^0.23b2 for opentelemetry-instrumentation-asyncpg

Updating dependencies
Resolving dependencies... (0.8s)

  SolverProblemError

  Because no versions of opentelemetry-instrumentation-asyncpg match >0.23b2,<0.24
   and opentelemetry-instrumentation-asyncpg (0.23b2) depends on opentelemetry-instrumentation (0.23b2), opentelemetry-instrumentation-asyncpg (>=0.23b2,<0.24) requires opentelemetry-instrumentation (0.23b2).
  And because opentelemetry-instrumentation (0.23b2) depends on opentelemetry-api (1.4.1), opentelemetry-instrumentation-asyncpg (>=0.23b2,<0.24) requires opentelemetry-api (1.4.1).
  And because opentelemetry-exporter-gcp-monitoring (1.0.0a0) depends on opentelemetry-api (>=1.10a0,<2.0.0)
   and no versions of opentelemetry-exporter-gcp-monitoring match >1.0.0-alpha.0,<2.0.0, opentelemetry-instrumentation-asyncpg (>=0.23b2,<0.24) is incompatible with opentelemetry-exporter-gcp-monitoring (>=1.0.0-alpha.0,<2.0.0).
  So, because sfjapi depends on both opentelemetry-exporter-gcp-monitoring (^1.0.0-alpha.0) and opentelemetry-instrumentation-asyncpg (^0.23b2), version solving failed.

so this is quite clear that this is because of opentelemetry-exporter-gcp-monitoring:

And because opentelemetry-exporter-gcp-monitoring (1.0.0a0) depends on opentelemetry-api (>=1.10a0,<2.0.0)

so i wonder if there is a typo in its setup here https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/b342c801b2a3827dd1206c1b5f387685a5248399/opentelemetry-exporter-gcp-monitoring/setup.cfg#L29 and if one should make it coherent with the rest ie make it dependant to 1.0.0a0 vs 1.10a0 at present.

currently install opentelemetry-exporter-gcp-monitoring alongside any other package seems like impossible or I'm missing something ?

euri10 avatar Jul 29 '21 15:07 euri10

You're right that the packages have been split up. Unfortunately, OTel metrics are still a work in progress, so they were not released along with the 1.0 API/SDK but moved into a separate branch and released as 1.10a0 several months back. And yes, it appears to currently be impossible to install that exporter still with any other packages, because opentelemetry-instrumentation is still pinning the API version (we fixed this for the individual instrumentation packages).

Thanks for pointing this out, I think this is a bug in the OTel packaging, I will bring it up with the Python group.

aabmass avatar Jul 29 '21 20:07 aabmass

I am curious though, have you written any custom metric instrumentation? It might be easiest to just remove this for now as the OTel metrics spec is getting mostly gutted right now.

aabmass avatar Jul 29 '21 20:07 aabmass

I am curious though, have you written any custom metric instrumentation? It might be easiest to just remove this for now as the OTel metrics spec is getting mostly gutted right now.

No I didn't write anything custom, relevant part of my current code using the "old" opentelemetry-exporter-google-cloud package that provides both metrics exporter and trace exporter is

    metrics.set_meter_provider(MeterProvider())
    meter = metrics.get_meter(__name__)
    metrics.get_meter_provider().start_pipeline(  # type: ignore[attr-defined]
        meter, CloudMonitoringMetricsExporter(), 5
    )
    requests_counter = meter.create_counter(
        name="429_counter",
        description="number of 429 requests",
        unit="1",
        value_type=int,
        enabled=True,
    )

.... blablabla ....

    if app_settings_loaded.tracing_enabled:
        trace.set_tracer_provider(TracerProvider())
        cloud_trace_exporter = CloudTraceSpanExporter(
            project_id="blablabla",
        )
        trace_provider: TracerProvider = trace.get_tracer_provider()  # type: ignore[assignment]
        trace_provider.add_span_processor(
            BatchExportSpanProcessor(cloud_trace_exporter)
        )
        FastAPIInstrumentor.instrument_app(app)
        AsyncPGInstrumentor().instrument()

euri10 avatar Jul 30 '21 06:07 euri10

requests_counter = meter.create_counter(
    name="429_counter",
    description="number of 429 requests",
    unit="1",
    value_type=int,
    enabled=True,
)

This is what I meant by custom metric instrumentation. I have a fix upstream for your issue https://github.com/open-telemetry/opentelemetry-python/pull/2012. Once that is released, you should be able to upgrade

aabmass avatar Aug 02 '21 14:08 aabmass

much appreciated @aabmass !

euri10 avatar Aug 02 '21 15:08 euri10

@aabmass and @euri10 , can this be closed out now?

punya avatar Sep 08 '21 15:09 punya

@aabmass and @euri10 , can this be closed out now?

I tried to install the same way as above and it's ok now. BUT, when running my code, I now have the same issue as https://github.com/open-telemetry/opentelemetry-python/issues/2137

euri10 avatar Oct 04 '21 09:10 euri10

for reference the packages used:

opentelemetry-exporter-gcp-trace = "1.0.0"
opentelemetry-exporter-gcp-monitoring = "1.0.0-alpha.0"
opentelemetry-instrumentation-fastapi = "0.24b0"
opentelemetry-instrumentation-asyncpg = "0.24b0"

euri10 avatar Oct 04 '21 09:10 euri10

The OTel python SIG is reworking metrics from scratch and I don't expect any more releases with metrics past the 1.10a version until we have a new working metrics prototype. If this is a big issue, I'd recommend creating an issue in the open-telemetry/opentelemetry-python repo to see if the old branch can be rebased and a release made.

aabmass avatar Oct 04 '21 19:10 aabmass

It's been a while.... Any update on this?

Right now it seems that you can only use opentelemetry for either metrics or tracing.

Judging how amazingly painful monitoring_v3 is it seems that python devs need to make a deal with the devil and neglect either metrics or tracing... Or is there some hackaround to get both working?

f0o avatar Oct 27 '22 12:10 f0o

I'm working on updating the Cloud Monitoring exporter to work with the stable metrics SDK. Hopefully should have something working in the next week or so.

aabmass avatar Nov 04 '22 05:11 aabmass

Fixed with https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/pull/204. The trace and monitoring exporters both now have the same wide dependency range:

  • https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/df0e9ac720eef60f2aaded7e1ce27ba449927aaa/opentelemetry-exporter-gcp-trace/setup.cfg#L29-L30
  • https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/df0e9ac720eef60f2aaded7e1ce27ba449927aaa/opentelemetry-exporter-gcp-monitoring/setup.cfg#L29-L30

Hoping to release this soon!

aabmass avatar Nov 08 '22 18:11 aabmass