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

integration example for apollo-server-express #81

Closed
2 tasks done
jitenderchand opened this issue Jun 17, 2020 · 5 comments
Closed
2 tasks done

integration example for apollo-server-express #81

jitenderchand opened this issue Jun 17, 2020 · 5 comments

Comments

@jitenderchand
Copy link

  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first
@dyladan
Copy link
Member

dyladan commented Jun 17, 2020

@jitenderchand there is no real context here to describe what you want. Are you looking for an example to manually trace apollo server express, or are you looking for an autoinstrumentation plugin? Are you currently working on this, or hoping someone else will do it?

@jitenderchand
Copy link
Author

@dyladan I was trying to set up tracing for my project. we are using the apollo-server-express. I followed the getting started guide to setup. It works with example and it automatically traced whenever I hit the backed API. However, when I tried to set up this with my project the setup was successful but whenever I was hitting graphql API it was not working, which means it was not sending any traced data to zipkin. I have tried to set up it with the following code.

"use strict";

const { LogLevel } = require("@opentelemetry/core");
const { NodeTracerProvider } = require("@opentelemetry/node");
const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");

const provider = new NodeTracerProvider({ logLevel: LogLevel.ERROR });

provider.addSpanProcessor(
  new SimpleSpanProcessor(
    new ZipkinExporter({
      serviceName: "getting-started"
      // If you are running your tracing backend on another host,
      // you can point to it using the `url` parameter of the
      // exporter config.
    })
  )
);

provider.register();
console.log("tracing initialized");

I also tried to follow the http example to send the trace manually. unfortunately, that didn't work as well.

My repository code which make API call.

async retrieveList(limit?: number, page?: number): Promise<any> {
        const url = new URL(`${this._baseURL}/v1/request/list`);
        const span = tracer.startSpan('makeRequest');
        return tracer.withSpan(span, async () => {
            const response = await this.get(url.toString());
            span.end();
           
            return {
                items: response.list
            };
        })
    } 

my tracer.js


'use strict';

import opentelemetry from "@opentelemetry/api";
import { NodeTracerProvider } from "@opentelemetry/node";
import { SimpleSpanProcessor } from "@opentelemetry/tracing";
import { ZipkinExporter } from "@opentelemetry/exporter-zipkin";

export default (serviceName: any) => {
    const provider = new NodeTracerProvider({
        plugins:{
            express: {
                enabled: true,
                path: '@opentelemetry/plugin-express'
            }
        }
    });
    const exporter = new ZipkinExporter({
        serviceName,
    });

    provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

    // Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
    provider.register();

    return opentelemetry.trace.getTracer('http-example');
};

So I know I am missing something, I have tried to search for example code where it can work with apollo-server-express but could not fine one

@jitenderchand
Copy link
Author

@dyladan I am still struggling to setup it with apollo graphql. Could you please point me to some document if we have any.

@dyladan
Copy link
Member

dyladan commented Jul 6, 2020

I'm sorry we don't have any examples specific for apollo

@vmarchaud
Copy link
Member

I'm gonna close this in favor of the issue for the plugin here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants