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

[Blog] Learn how to instrument nginx with OpenTelemetry #1624

Merged
merged 5 commits into from
Aug 19, 2022

Conversation

svrnm
Copy link
Member

@svrnm svrnm commented Aug 17, 2022

@DebajitDas & @kpratyus have released a first version of the nginx module, in this blog post I give a hands on introduction on how to use it.

Preview: https://deploy-preview-1624--opentelemetry.netlify.app/blog/2022/instrument-nginx/

@svrnm svrnm requested review from a team August 17, 2022 14:55
Copy link
Contributor

@chalin chalin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some copyedits, but they are sprinkled out, so I'm just going to commit the delta (9e24102, see below). Please review the commit and feel free to comment / adjust as necessary. Hopefully, this is ok with you.

@chalin
Copy link
Contributor

chalin commented Aug 19, 2022

Since the images will very likely only be used in this post, I've repackaged the files as a Hugo page bundle (via 9f08fd3). PTAL

@svrnm
Copy link
Member Author

svrnm commented Aug 19, 2022

@chalin thanks for copy edits, packacking & committing them directly :-) all the changes are looking good to me.

Copy link
Contributor

@chalin chalin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad that you're ok with the changes. Then this LGTM! :)

@chalin chalin merged commit 70bf281 into open-telemetry:main Aug 19, 2022
@svrnm svrnm deleted the nginx-blog branch May 11, 2023 07:54
@880831ian
Copy link
Contributor

880831ian commented Jul 21, 2023

Hi author, I followed this blog step by step, and encountered the following problem in the final frontend Node.js. When the frontend finished running docker, the following error would be displayed:

test-frontend-1   | /app/app.js:14
test-frontend-1   | sdk.start().then(() => {
test-frontend-1   |            ^
test-frontend-1   |
test-frontend-1   | TypeError: Cannot read properties of undefined (reading 'then')
test-frontend-1   |     at Object.<anonymous> (/app/app.js:14:12)
test-frontend-1   |     at Module._compile (node:internal/modules/cjs/loader:1198:14)
test-frontend-1   |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
test-frontend-1   |     at Module.load (node:internal/modules/cjs/loader:1076:32)
test-frontend-1   |     at Function.Module._load (node:internal/modules/cjs/loader:911:12)
test-frontend-1   |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
test-frontend-1   |     at node:internal/main/run_main_module:22:47

I tried adapting the Node.js program to:

const opentelemetry = require('@opentelemetry/sdk-node');
const {
  getNodeAutoInstrumentations,
} = require('@opentelemetry/auto-instrumentations-node');
const {
  OTLPTraceExporter,
} = require('@opentelemetry/exporter-trace-otlp-http');
const express = require('express');
const http = require('http');

const sdk = new opentelemetry.NodeSDK({
  traceExporter: new OTLPTraceExporter(),
  instrumentations: [getNodeAutoInstrumentations()],
});

(async () => {
  await sdk.start();

  const app = express();

  app.get('/', (_, response) => {
    const options = {
      hostname: 'nginx',
      port: 80,
      path: '/',
      method: 'GET',
    };
    const req = http.request(options, (res) => {
      console.log(`statusCode: ${res.statusCode}`);
      res.on('data', (d) => {
        response.send('Hello World');
      });
    });
    req.end();
  });

  app.listen(8000, () => {
    console.log('Listening for requests on port 8000');
  });
})();

It works fine, but in jaeger what is shown is not accessing the frontend

截圖 2023-07-21 下午4 12 48


Is there any good suggestion to adjust the direction? Thank ~~~

@svrnm
Copy link
Member Author

svrnm commented Jul 21, 2023

@880831ian can you raise an independent issue for your question, as this PR is closed

@880831ian
Copy link
Contributor

@svrnm ok, I open a new issue, thank

@880831ian
Copy link
Contributor

I have opened a new issue, please help
#3059

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

Successfully merging this pull request may close these issues.

4 participants