Skip to content

Commit

Permalink
Merge pull request #36 from infrastackai/npm-edge-support
Browse files Browse the repository at this point in the history
startotel deprecation, grpc and http/proto protocol support, nextjs s…
  • Loading branch information
ferhatkorkmaz11 authored Oct 21, 2024
2 parents d140a66 + 0914d94 commit 2f633a4
Show file tree
Hide file tree
Showing 17 changed files with 743 additions and 799 deletions.
6 changes: 3 additions & 3 deletions examples/expressjs/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { startOtel } from "@infrastack/otel";
import { Infrastack } from "@infrastack-otel";

startOtel({
serviceName: "infrastack-expressjs-example",
Infrastack.init({
serviceName: "Infrastack ExpressJS Example",
});
6 changes: 3 additions & 3 deletions examples/nestjs/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { startOtel } from '@infrastack/otel';
import { Infrastack } from "@infrastack-otel";

startOtel({
serviceName: 'nestjs-otel-example',
Infrastack.init({
serviceName: "Infrastack NestJS Example",
});
5 changes: 0 additions & 5 deletions examples/nextjs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
const nextConfig = {
experimental: {
instrumentationHook: true, // To enable instrumentation
serverComponentsExternalPackages: [
// To utilize node.js specific features in a next.js environment
"@opentelemetry/auto-instrumentations-node",
"@opentelemetry/sdk-node",
],
},
};

Expand Down
12 changes: 5 additions & 7 deletions examples/nextjs/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
const { startOtel } = await import("@infrastack/otel");
import { Infrastack } from "@infrastack-otel";

startOtel({
serviceName: "infrastack-nextjs-example",
});
}
export async function register() {
Infrastack.init({
serviceName: "Infrastack NextJS Example",
});
}
19 changes: 19 additions & 0 deletions packages/javascript/otel/.changeset/selfish-melons-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@infrastack/otel": minor
---

# startOtel Deprecation
The `startOtel` function has been replaced with `Infrastack.init`. We believe that we will be bringing more functionality to the package, and this will make it easier for us to do so.

# Protocol Support
We have added support for gRPC as a protocol. This is available as an option in the `init` function under the enum `Protocol`. The default protocol is GRPC.

# NextJS Performance Improvements
We were aware of Vercel deployed Next.js applications had problems. We have made some performance improvements to the SDK to help with this.

Now, we are not directly depending on the `@opentelemetry/sdk-node` package since we had bunch of import errors in the Next.js framework.

From now on, `next.config.mjs` is more straightforward.

Also, we adapted some `vercel` related optimizations by using the `@vercel/otel` packages some functionalities, specifically the `VercelRequestContext` and flushing the tracer when the request ends.

10 changes: 5 additions & 5 deletions packages/javascript/otel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ $ npm install @infrastack/otel
To configure Infrastack SDK, call the `init` function in the `instrumentation.ts`:

```javascript
import { startOtel } from "@infrastack/otel";
startOtel();
import { Infrastack } from "@infrastack/otel";
Infrastack.init();
```

This will capture all the configurations from the `.env` file. This produces an output similar to below:
Expand Down Expand Up @@ -59,7 +59,7 @@ You can initialize the SDK with configuration, which overrides the environment v
1. First, gather the related imports from `@infrastack/otel` in your `instrumentation.ts`

```javascript
import { startOtel, Instrumentation, Configuration, Environment, Tag } from "@infrastack/otel";
import { Infrastack, Instrumentation, Configuration, Environment, Tag } from "@infrastack/otel";
```
2. Then, set up your SDK options.

Expand All @@ -82,7 +82,7 @@ const configuration : Configuration = {

3. Initialize the Infrastack SDK
```javascript
startOtel(configuration);
Infrastack.init(configuration);
```

---
Expand All @@ -92,7 +92,7 @@ Partial configuration is also possible. For example:
const configuration : Configuration = {
logsEnabled:false
}
startOtel(configuration);
Infrastack.init(configuration);
```
This disables Infrastack SDK logs but collects the rest of the configuration from your `.env` file if available.

Expand Down
Loading

0 comments on commit 2f633a4

Please sign in to comment.