{"id":25299194,"url":"https://github.com/frankfarrell/jlambdadog","last_synced_at":"2025-10-29T05:32:28.462Z","repository":{"id":88518735,"uuid":"167169345","full_name":"frankfarrell/jlambdadog","owner":"frankfarrell","description":"Java library for sending Datadog metrics from AWS Lambda","archived":false,"fork":false,"pushed_at":"2019-01-24T12:38:56.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T22:44:51.715Z","etag":null,"topics":["aws-lambda","cloudwatch-metrics","datadog","datadog-metrics","java"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frankfarrell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-23T11:08:53.000Z","updated_at":"2019-01-24T12:38:57.000Z","dependencies_parsed_at":"2023-07-22T22:00:20.629Z","dependency_job_id":null,"html_url":"https://github.com/frankfarrell/jlambdadog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/frankfarrell/jlambdadog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fjlambdadog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fjlambdadog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fjlambdadog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fjlambdadog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frankfarrell","download_url":"https://codeload.github.com/frankfarrell/jlambdadog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fjlambdadog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260131537,"owners_count":22963448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","cloudwatch-metrics","datadog","datadog-metrics","java"],"created_at":"2025-02-13T04:53:59.164Z","updated_at":"2025-10-29T05:32:28.395Z","avatar_url":"https://github.com/frankfarrell.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jLambdaDog\n(Apologies for the silly name ) \n\nJava library for sending Datadog metrics from AWS Lambda via Cloudwatch logs. See https://docs.datadoghq.com/integrations/amazon_lambda/ for details. \n\nTrack counters, gauges and histograms.\n\nEssentially it automates this: \n\n```\nTo send custom metrics to Datadog from your Lambda logs, print a log line from your Lambda, using the following format:\n\nMONITORING|\u003cunix_epoch_timestamp\u003e|\u003cvalue\u003e|\u003cmetric_type\u003e|\u003cmetric_name\u003e|#\u003ctag_list\u003e\nWhere:\n\nMONITORING signals to the Datadog integration that it should collect this log entry.\n\n\u003cunix_epoch_timestamp\u003e is in seconds, not milliseconds.\n\n\u003cvalue\u003e MUST be a number (i.e. integer or float).\n\n\u003cmetric_type\u003e is count, gauge, histogram, or check.\n\n\u003cmetric_name\u003e uniquely identifies your metric and adheres to the metric naming policy.\n\n\u003ctag_list\u003e is optional, comma separated, and must be preceded by #. The tag function_name:\u003cname_of_the_function\u003e is automatically applied to custom metrics.\n\nNote: The sum for each timestamp is used for counts and the last value for a given timestamp is used for gauges. It is not recommended to print a log statement every time you increment a metric, as this increases the time it takes to parse your logs. Continually update the value of the metric in your code, and print one log statement for that metric before the function finishes.\n\n```\n\n# How to use?\n\nInitialise your DatadogLambdaMetricRegistry instance with default tags and set of Histogram expansions, both optional. \n```java\nimport com.github.frankfarrell.jlambdadog.*;\n\npublic class MyHandler implements RequestStreamHandler {\n\n    private final DatadogLambdaMetricRegistry registry;\n\n    public MyHandler() throws IOException {\n        this.registry = new DatadogLambdaMetricRegistry();\n        \n        //or set the default tags for all metrics\n        this.registry = new DatadogLambdaMetricRegistry(getDefaultTags());\n        \n        //or set the tags and the set of expansions for histograms\n        final EnumSet\u003cExpansion\u003e expansions = EnumSet.of(Expansion.MEDIAN);\n        this.registry = new DatadogLambdaMetricRegistry(getDefaultTags(), expansions);\n    }\n\n    @Override\n    public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {\n        \n        //Do some work\n        \n        //Increment a counter\n        registry.increment(\"my.lovely.counter\", 4L);\n        \n        //time some method\n        final long startTime = System.currentTimeMillis();\n        //Some work here\n        final long endTime = System.currentTimeMillis();\n        final long duration = applicationEndTime - applicationStartTime;\n        \n        //Track it in an in memory histogram -\u003e Use this if you are processing events in batches\n        registry.sample(\"my.lovely.sample\", duration);\n        \n        //Track it as a gauge -\u003e Use this for once off measured events, or if the timestamp of the event is important\n        registry.gauge(\"my.lovely.gauge\", duration, Instant.now().getEpochSecond());\n        \n        //TODO, yet to be implemented\n        //Track it as a histogram -\u003e Use this for once off measured events, or if the timestamp of the event is important\n        registry.histogram(\"my.lovely.historgam\", duration);\n            \n        //Make sure you call this at the end or at any time you want to print metrics. \n        registry.printMetrics();\n    }\n    \n    private Map\u003cString, String\u003e getDefaultTags(){\n        final Map\u003cString, String\u003e tags = new HashMap\u003c\u003e();\n        tags.put(\"aws_region\", System.getenv(\"AWS_REGION\")); //Good practice to use Env variables for this sort of thing\n        return tags;\n    }\n}\n\n```\n\n# Dependencies\n\nThe only dependency is `com.codahale.metrics:metrics-core`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankfarrell%2Fjlambdadog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankfarrell%2Fjlambdadog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankfarrell%2Fjlambdadog/lists"}