Skip to content
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

@opentelemetry/exporter-collector-grpc not connecting after 0.20.0 upgrade #2264

Closed
brunoluiz opened this issue Jun 8, 2021 · 11 comments
Closed
Labels
bug Something isn't working stale

Comments

@brunoluiz
Copy link
Contributor

brunoluiz commented Jun 8, 2021

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

  • Collector: otel/opentelemetry-collector-contrib:0.27.0
  • SDK: 0.20.0

What version of Node are you using?

v12.20.0

Please provide the code you used to setup the OpenTelemetry SDK

import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { CollectorTraceExporter } from '@opentelemetry/exporter-collector-grpc';
import { NodeTracerProvider } from '@opentelemetry/node';

export class OpenTelemetry {
  static register({ serviceName, collectorUrl, instrumentations }) {
    const provider = new NodeTracerProvider();

    if (collectorUrl != false && collectorUrl != undefined) {
      const collectorExporter = new CollectorTraceExporter({
        serviceName: serviceName,
        url: collectorUrl,
      });
      provider.addSpanProcessor(new SimpleSpanProcessor(collectorExporter));
    }

    provider.register();

    registerInstrumentations({
      tracerProvider: provider,
      instrumentations,
    });

    ['SIGINT', 'SIGTERM'].forEach((signal) => {
      process.on(signal, () => provider.shutdown().catch(console.error));
    });
  }
}

What did you do?

Call OpenTelemetry.register({ serviceName: 'service', url: 'localhost:4317', instrumentations: [] ); on the top of src/index.js.

What did you expect to see?

My OpenTelemetry collector is running in kube (port-forwarded). I was expecting the NodeJS service to connect to it, returning a Handling connection for 4317 and registering the trace at our internal Jaeger (could be other tracing service).

What did you see instead?

No Handling connection for 4317 and no trace available

Additional context

I ran the code above with both 0.20.0 and 0.19.0 versions. It only give the expected behaviour on version 0.19.0.

@brunoluiz brunoluiz added the bug Something isn't working label Jun 8, 2021
@sv2
Copy link

sv2 commented Jun 8, 2021

FYI, it will not connect if url parameter is specified, and the value is without protocol, i.e. 'localhost:4317'. In my tests, if I specify protocol 'grpc://' it connects as expected in 0.20.0:

const collectorOptions = {
  url: 'grpc://localhost:4327', 
};
const exporterCollector = new CollectorTraceExporter(collectorOptions);

@brunoluiz
Copy link
Contributor Author

Well, updating the URL to grpc://... definitely worked in terms of connection. But, it still didn't register any traces 😞

@brunoluiz
Copy link
Contributor Author

Tomorrow I will try to find sometime to understand why it is not sending trace data across. Meanwhile, I opened a PR to fix the defaults and document this a bit better.

@andreabrigantisky
Copy link

Using the 0.20.0 locally I see that the serviceName is ignored and instead I see traces with this scaring format:

unknown_service:/Users/abt19/.nvm/versions/node/v14.17.0/bin/node: HTTP POST

Maybe it's related to the missing traces.

@dyladan
Copy link
Member

dyladan commented Jun 16, 2021

@brunoluiz have you had any luck figuring out what happened?

@brunoluiz
Copy link
Contributor Author

brunoluiz commented Jun 18, 2021

No luck, but about the serviceName above, I am quite sure this might be the culprit: 56c032e

I just don't understand how this is actually set. I wonder if it is just through env variables or there is an undocumented way to do so.

Screenshot 2021-06-18 at 10 57 17

Another interesting thing is: the unknown service bit only happens with me if I use @opentelemetry/exporter-collector (default on examples). The @opentelemetry/exporter-collector-grpc doesn't export anything it seems, even with the correct URL config.

@sv2
Copy link

sv2 commented Jun 18, 2021

I managed to set service name like this:

// Set service name
tracerProvider.resource.attributes['service.name'] = 'spectest';
const collectorOptions = {
  url: 'grpc://localhost:4327',
};
const exporterCollector = new CollectorTraceExporter(collectorOptions);
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(exporterCollector));

There are notes in readmes of opentelemetry-exporter-* packages, which says service name is now not the part of exporter config. So looks like it was removed ....

Service Name
The OpenTelemetry Collector Exporter does not have a service name configuration. In order to set the service name, use the service.name resource attribute as prescribed in the OpenTelemetry Resource Semantic Conventions.

https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-collector

@jessebond2
Copy link

This change to serviceName is unintuitive. I just ran into the same issue.

@vmarchaud
Copy link
Member

This change to serviceName is unintuitive. I just ran into the same issue.

this is required by the specification to use the resource sdk to do this: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service. I'm pretty sure we can override this at the exporter level (see jaeger for example)

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Feb 28, 2022
@github-actions
Copy link

This issue was closed because it has been stale for 14 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

6 participants