{"id":15222201,"url":"https://github.com/googlecloudplatform/cloud-trace-java","last_synced_at":"2025-10-03T15:30:34.183Z","repository":{"id":57724676,"uuid":"41767364","full_name":"GoogleCloudPlatform/cloud-trace-java","owner":"GoogleCloudPlatform","description":null,"archived":true,"fork":false,"pushed_at":"2018-05-07T16:23:08.000Z","size":867,"stargazers_count":46,"open_issues_count":7,"forks_count":42,"subscribers_count":44,"default_branch":"master","last_synced_at":"2024-12-18T08:40:02.365Z","etag":null,"topics":["cloud","google","java","stackdriver","trace"],"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/GoogleCloudPlatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-01T22:46:40.000Z","updated_at":"2024-11-05T15:55:25.000Z","dependencies_parsed_at":"2022-09-02T07:12:20.989Z","dependency_job_id":null,"html_url":"https://github.com/GoogleCloudPlatform/cloud-trace-java","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-trace-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-trace-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-trace-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-trace-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleCloudPlatform","download_url":"https://codeload.github.com/GoogleCloudPlatform/cloud-trace-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235146547,"owners_count":18943281,"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":["cloud","google","java","stackdriver","trace"],"created_at":"2024-09-28T15:11:01.887Z","updated_at":"2025-10-03T15:30:33.575Z","avatar_url":"https://github.com/GoogleCloudPlatform.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Google is no longer actively updating this repository, and we recommend that developers use OpenCensus to send data to Stackdriver Trace. These libraries will continue to work for existing projects.\n\n# Google Cloud Trace SDK for Java\n\n[![Build Status][travis-image]][travis-url] [![Maven Central][maven-image]][maven-url]\n\nStackdriver Trace is a distributed tracing system for Google Cloud Platform that collects latency data from your applications and displays it in the Google Cloud Platform Console. You can see detailed near real-time insights into application performance. Stackdriver Trace automatically analyzes all your application traces to generate in-depth performance reports to surface application performance degradations and call flow performance bottlenecks.\n\nThe Java SDK provides programmatic access to the concepts of tracing, allowing you to start and stop trace spans, annotate spans, and write the data to Stackdriver Trace or your own service using your choice of sink.\n\n## Prerequisites\n\nTo use this SDK, you must have an application that you'd like to trace. The app can be on Google Cloud Platform, on-premise, or another cloud platform.\n\nIf you'd like to integrate the SDK with the Stackdriver Trace service, in order view your traces in the Cloud Console UI, you must:\n\n1. [Create a Cloud project](https://support.google.com/cloud/answer/6251787?hl=en).\n2. [Enable billing](https://support.google.com/cloud/answer/6288653#new-billing).\n3. [Enable the Stackdriver Trace API](https://console.cloud.google.com/apis/api/cloudtrace.googleapis.com/overview).\n\nThese steps enable the API but don't require that your app is hosted on Google Cloud Platform.\n\nIf you're using the Google Cloud Platform to host your application, this SDK is a good choice for apps on App Engine flexible environment, Google Compute Engine, and Google Container Engine. Apps on App Engine standard environment are traced automatically and don't require the use of this SDK.\n\n## Project overview\n\nTo use the SDK, add the following Maven dependency to your application's `pom.xml` file:\n\n```xml\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003ecore\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n```\nAdditionally, add a dependency on a `TraceService` artifact which will process the trace events you create.\n* The Logging service will write trace events to the logs.\n```xml\n  \u003cdependency\u003e\n    \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n    \u003cartifactId\u003elogging-service\u003c/artifactId\u003e\n  \u003c/dependency\u003e\n```\n* The Stackdriver Trace gRPC API `TraceService` will write traces to the Stackdriver Trace API using gRPC.\n```xml\n  \u003cdependency\u003e\n    \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n    \u003cartifactId\u003etrace-grpc-api-service\u003c/artifactId\u003e\n  \u003c/dependency\u003e\n```\n\nIf you'd like to build the SDK yourself, create a clone of this project on your local machine:\n\n    git clone https://github.com/GoogleCloudPlatform/cloud-trace-java.git \n\nThe project is organized into a core module that contains the main library classes and interfaces, and optional submodules for platform-specific additions (servlets, etc.). There is a top-level Maven POM that builds them all.\n\nTo build the project, from its root directory run:\n\n    mvn install\n\n\n## Hello, Trace!\n### Writing to the Stackdriver Trace API\nThe following sample writes a trace span to the Stackdriver Trace API using gRPC.\n* Add the dependencies to your project.\n```xml\n  \u003cdependencies\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003ecore\u003c/artifactId\u003e\n      \u003cversion\u003eVERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003eservice\u003c/artifactId\u003e\n      \u003cversion\u003eVERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003etrace-grpc-api-service\u003c/artifactId\u003e\n      \u003cversion\u003eVERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n  \u003c/dependencies\u003e\n```\n* Write traces.\n```java\npublic class Example {\n  public static void main(String[] args) throws IOException {\n    // Initialize the Tracer.\n    TraceService traceService = TraceGrpcApiService.builder()\n        // Set the projectId.\n        .setProjectId(\"my-project-id\")\n        // Uncomment this if you want to provide your own credentials for the Stackdriver Trace API.\n        // On GCE, this is optional because the Application Default Credentials are used by default.\n        //.setCredentials(\n        //    GoogleCredentials.fromStream(new FileInputStream(\"/path/to/my/credentials.json\")))\n        // Use a short delay of 1 second for this example. In production, you may want to use a\n        // higher value so that more trace events are batched together in a single request to the\n        // Stackdriver Trace API. By default, the delay is 15 seconds.\n        .setScheduledDelay(1)\n    .build();\n    Trace.init(traceService);\n\n    Tracer tracer = Trace.getTracer();\n    TraceContext context = tracer.startSpan(\"test-span\");\n    tracer.endSpan(context);\n  }\n}\n```\n### Basic logging\nThe following sample writes a trace span, containing a stack trace, to logs.\n* Add the dependencies to your project.\n```xml\n  \u003cdependencies\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003ecore\u003c/artifactId\u003e\n      \u003cversion\u003eVERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003eservice\u003c/artifactId\u003e\n      \u003cversion\u003eVERSION\u003c/version\u003e\n    \u003c/dependency\u003e\n    \u003c!-- Adding this dependency auto-configures tracing to write to logs. --\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.google.cloud.trace\u003c/groupId\u003e\n      \u003cartifactId\u003elogging-service\u003c/artifactId\u003e\n      \u003cversion\u003eVERSION\u003c/version\u003e\n      \u003cscope\u003eruntime\u003c/scope\u003e\n    \u003c/dependency\u003e\n  \u003c/dependencies\u003e\n```\n* Write traces.\n```java\npublic class Example {\n  public static void main(String[] args) {\n    Tracer tracer = Trace.getTracer();\n\n    // Create a span using the given timestamps.\n    TraceContext context = tracer.startSpan(\"my span 1\");\n    StackTrace.Builder stackTraceBuilder = ThrowableStackTraceHelper.createBuilder(new Exception());\n    tracer.setStackTrace(context, stackTraceBuilder.build());\n    tracer.endSpan(context);\n  }\n}\n```\n## What's next\n\n(coming soon: Concepts, Trace Java SDK on Google Cloud Platform)\n\n\n[travis-image]: https://travis-ci.org/GoogleCloudPlatform/cloud-trace-java.svg?branch=master\n[travis-url]: https://travis-ci.org/GoogleCloudPlatform/cloud-trace-java\n[maven-image]: https://maven-badges.herokuapp.com/maven-central/com.google.cloud.trace/sdk/badge.svg\n[maven-url]: https://maven-badges.herokuapp.com/maven-central/com.google.cloud.trace/sdk\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fcloud-trace-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglecloudplatform%2Fcloud-trace-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fcloud-trace-java/lists"}