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 layer for Datadog extension #404

Closed
wants to merge 1 commit into from
Closed

Conversation

ramsey
Copy link

@ramsey ramsey commented Mar 1, 2023

This PR adds a layer containing the Datadog Agent and ddtrace extension, following the approach @deleugpn describes at https://blog.deleu.dev/datadog-aws-lambda-php/

I have built the layers and tested this with my own serverless application, and it properly sends logging and tracing information to Datadog.

Here's an example serverless.yml configuration for this layer:

service: my-service

custom:
  datadog:
    apiKey: ${env:DD_API_KEY}
    env: ${env:MY_DEPLOYMENT_ENVIRONMENT}
    logLevel: ${env:DD_LOG_LEVEL, 'warn'}
    service: ${self:service}
    version: ${env:MY_VERSION}

plugins:
  - ./vendor/bref/bref
  - ./vendor/bref/extra-php-extensions

provider:
  name: aws
  region: us-east-1
  runtime: provided.al2
  layers:
    - ${bref:layer.php-82}
    - ${bref-extra:datadog-php-82}
  deploymentMethod: direct
  environment:
    DD_API_KEY: ${self:custom.datadog.apiKey}
    DD_ENV: ${self:custom.datadog.env}
    DD_LOG_LEVEL: ${self:custom.datadog.logLevel}
    DD_SERVICE: ${self:custom.datadog.service}
    DD_TRACE_CLI_ENABLED: 1
    DD_VERSION: ${self:custom.datadog.version}

functions:
  sayHello:
    handler: ./src/sayHello.php

This closes #35, when accepted.

@ramsey ramsey force-pushed the datadog-layer branch 2 times, most recently from 4965219 to 015d14a Compare March 3, 2023 23:46
@ramsey ramsey marked this pull request as ready for review March 3, 2023 23:55
@ramsey ramsey changed the title Add layer for Datadog extensions Add layer for Datadog extension Mar 3, 2023
@maksym-odanets
Copy link
Contributor

Hey Ramsey, team

Re that article you are referring (https://blog.deleu.dev/datadog-aws-lambda-php/)
We also followed it to integrate DD into Bref Laravel lambda.

After integration, found lots of notices in CloudWatch like:
NOTICE: PHP message: Error loading deferred integration 'DDTrace\Integrations\Predis\PredisIntegration' from DDTrace\Integrations\load_deferred_integration
(*the same is for eloquent, pdo etc)

Right now - discussing that issue with DD support.

I wonder - does anyone have the same notices?

@ramsey
Copy link
Author

ramsey commented Mar 8, 2023

@wolflingorg, the blog post doesn't mention copying over the integrations, which it sounds like you're trying to use. In order to use those, you need a line like this:

COPY --from=ext /opt/datadog/ /opt/datadog

You also need to make sure your Datadog INI settings are configured to link properly to the integrations code in /opt/datadog, which the default 98-ddtrace.ini file includes.

This is all handled in this pull request. If you'd like to give it a try and report back, that would help a lot. Thanks!

@maksym-odanets
Copy link
Contributor

maksym-odanets commented Mar 13, 2023

Hey,

Thanks for sharing an example & comments. You're right, looks like we missed something. After applying what you suggested, all looks good.

Thanks a lot

The only thing I noticed: you installed DD without an "--enable-profiling" flag (and also commented out profiling in the .ini file)... Is there any reason why?

@ramsey
Copy link
Author

ramsey commented Mar 13, 2023

The only thing I noticed: you installed DD without an "--enable-profiling" flag (and also commented out profiling in the .ini file)... Is there any reason why?

My understanding is that profiling is still in beta. The extension .so file is still available in the layer, so if you want to enable it, you can follow the instructions for Bref to create custom INI configuration and enable it.

@mnapoli
Copy link
Member

mnapoli commented Mar 29, 2023

Hi, to provide some update here: on my end it looks good, but unfortunately we released Bref v2 which impacts the build here. I'm afraid you would have to rebase (you can look at how Dockerfiles look in the repo now to get some examples)

@ramsey ramsey closed this Mar 31, 2023
@fbnfgc
Copy link

fbnfgc commented Apr 12, 2023

Hi, we are looking forward to use datadog. We're still using bref v1 but we are planning to migrate to v2 in a near future. Are you still working on this @ramsey? Do you need some help?

@ramsey
Copy link
Author

ramsey commented Apr 12, 2023

I went in a different direction, for now. Soon, I’ll open a new pull request with the changes I made.

@fbnfgc
Copy link

fbnfgc commented Apr 12, 2023

Thanks!

@ramsey ramsey mentioned this pull request Jul 27, 2023
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.

Datadog extension
4 participants