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

add xray enabled api #44

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This repo contains full examples, tested against the most recent releases of Win

## Examples

### Wing - Generic
### Wing - Generic Winglang

- [Hello Wing](./examples/hello-wing)
- [HTTP Api Basic Auth](./examples/api-basic-auth/)
Expand All @@ -16,9 +16,17 @@ This repo contains full examples, tested against the most recent releases of Win
- [S3 Backend](./examples/s3-backend)
- [Terraform Backend](https://github.com/winglang/terraform-backend) (dedicated repository)
- [React Website](./examples/react-website)
- [Todo](./examples/todo/)
- [Multiplayer Video Game](./examples/multiplayer-videogame/)

### Wing - Typescript

- [Minimal Typescript SDK Demo](./examples/typescript/)
- [Typescript SDK meets HonoJS](./examples/typescript-hono/)

### Wing - Provider Specific

- [Wing API with AWS Platform to enable X-Ray via Open Telemetry](./examples/provider-specific/api-xray-enabled)
- [AWS CDK Hello World](./examples/provider-specific/awscdk-hello-wing)
- [AWS CDK Docker Function](./examples/provider-specific/awscdk-docker-python-lambda)
- [Terraform Module](./examples/provider-specific/cdktf-terraform-hcl-module)
Expand Down
1 change: 1 addition & 0 deletions examples/provider-specific/api-xray-enabled/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.js
27 changes: 27 additions & 0 deletions examples/provider-specific/api-xray-enabled/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# HTTP API with X-Ray and Lambda OpenTelemetry

This is a [HTTP API](https://www.winglang.io/docs/standard-library/cloud/api) example where both the API Gateway and Lambda handlers are enabled with X-Ray. It's using [aws-otel](https://aws-otel.github.io/) for most of the heavy lifting.

Each Lambda Handler will have OpenTelemetry config injected, without changing any code or adding aws-xray sdks. This works by adding an OpenTelemetry Lambda Layer, which unfortunately adds a bit of cold start time (500ms - 1s).

This works by defining a custom [platform](./platform/index.ts) for AWS as described [here](https://www.winglang.io/docs/concepts/platforms#custom-platforms).

This got extracted from building internal tools for [wing.cloud](https://wing.cloud).

## Prerequisite

Please make sure to use a current and working setup of the [wing cli](https://docs.winglang.io/getting-started/installation)

## Usage

### Wing Console

```
wing it
```

### Wing Tests

```
wing test --debug main.w
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions examples/provider-specific/api-xray-enabled/main.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
bring cloud;
bring util;
bring http;
bring expect;

let api = new cloud.Api();

api.get("/hello", inflight (req) => {
return {
status: 200,
headers: {
"Content-Type" => "text/plain"
},
body: "hello world"
};
});


test "it should respond with 200" {
let response = http.get("{api.url}/hello");
expect.equal(response.status, 200);
}
Loading
Loading