";let n=document.getElementById("TableOfContents");n&&(n.innerHTML=e)}rerender(){this.renderFilterMenu(),this.renderPageContent(),this.populateRightNav(),this.runHooks("afterRerender")}renderPageContent(){let e={};Object.keys(this.ifFunctionsByRef).forEach(t=>{let s=this.ifFunctionsByRef[t],o=s.value,n=(0,h.reresolveFunctionNode)(s,{variables:this.selectedValsByTraitId});this.ifFunctionsByRef[t]=n,o!==n.value&&(e[t]=n.value)});let t=document.getElementsByClassName("cdoc__toggleable");for(let n=0;n{this.fitCustomizationMenuToScreen()})}addDropdownEventListeners(){let e=document.getElementsByClassName("cdoc-dropdown");for(let t=0;t{let t=e.target;for(;!t.classList.contains("cdoc-dropdown")&&t.parentElement;)t=t.parentElement;let n=t.classList.toggle("cdoc-dropdown__expanded");t.setAttribute("aria-expanded",n.toString())});document.addEventListener("keydown",e=>{if(e.key==="Enter"){let t=e.target;t.classList.contains("cdoc-filter__option")&&t.click()}}),document.addEventListener("click",t=>{for(let n=0;nthis.handleFilterSelectionChange(e));this.addDropdownEventListeners()}locateFilterSelectorEl(){let e=document.getElementById("cdoc-selector");return!!e&&(this.filterSelectorEl=e,!0)}applyFilterSelectionOverrides(){let s=Object.keys(this.selectedValsByTraitId),e=!1,t=this.browserStorage.getTraitVals();Object.keys(t).forEach(n=>{s.includes(n)&&this.selectedValsByTraitId[n]!==t[n]&&(this.selectedValsByTraitId[n]=t[n],e=!0)});let n=(0,j.getTraitValsFromUrl)({url:new URL(window.location.href),traitIds:s});return Object.keys(n).forEach(t=>{this.selectedValsByTraitId[t]!==n[t]&&(this.selectedValsByTraitId[t]=n[t],e=!0)}),e}updateEditButton(){let t=document.getElementsByClassName("toc-edit-btn")[0];if(!t)return;let e=t.getElementsByTagName("a")[0];e&&(e.href=e.href.replace(/\.md\/$/,".mdoc.md/"))}revealPage(){this.runHooks("beforeReveal"),this.filterSelectorEl&&(this.filterSelectorEl.style.position="sticky",this.filterSelectorEl.style.backgroundColor="white",this.filterSelectorEl.style.paddingTop="10px",this.filterSelectorEl.style.visibility="visible",this.filterSelectorEl.style.zIndex="1000");let e=document.getElementById("cdoc-content");e&&(e.style.visibility="visible"),this.runHooks("afterReveal")}renderFilterMenu(){if(!this.filterSelectorEl||!this.filtersManifest)throw new Error("Cannot render filter selector without filtersManifest and filterSelectorEl");let e=(0,l.resolveFilters)({filtersManifest:this.filtersManifest,valsByTraitId:this.selectedValsByTraitId});Object.keys(e).forEach(t=>{let n=e[t];this.selectedValsByTraitId[t]=n.currentValue});let t=(0,y.buildCustomizationMenuUi)(e);this.filterSelectorEl.innerHTML=t,this.fitCustomizationMenuToScreen(),this.addFilterSelectorEventListeners()}fitCustomizationMenuToScreen(){let e=document.getElementById(g);if(!e)return;let s=e.classList.contains(n),t=document.getElementById(v);if(!t)throw new Error("Dropdown menu not found");let o=document.getElementById(b);if(!o)throw new Error("Menu wrapper not found");let i=e.scrollWidth>o.clientWidth;!s&&i?(e.classList.add(n),t.classList.remove(n)):s&&!i&&(e.classList.remove(n),t.classList.add(n))}get cdocsState(){return{selectedValsByTraitId:this.selectedValsByTraitId,ifFunctionsByRef:this.ifFunctionsByRef,filtersManifest:this.filtersManifest,browserStorage:this.browserStorage,filterSelectorEl:this.filterSelectorEl}}};e.ClientFiltersManager=r,t=r,s={value:void 0}}),y=e(e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=j();window.clientFiltersManager=t.ClientFiltersManager.instance}),y()})()Instrumenting a .NET Cloud Run Function
If you are new to Datadog serverless monitoring, launch the Datadog CLI in interactive mode to guide your first installation for a quick start.
datadog-ci cloud-run instrument -i
To permanently install Datadog for your production applications, run the instrument command in your CI/CD pipelines after your normal deployment. You can specify multiple services to instrument by passing multiple --service flags.
After deploying your Cloud Run app, you can manually modify your app’s settings to enable Datadog monitoring.
Create a Volume with In-Memory volume type.
Add a new container with image URL: gcr.io/datadoghq/serverless-init:latest.
Add the volume mount to every container in your application. Choose a path such as /shared-volume, and remember it for the next step. For example:
Add the following environment variables to your serverless-init sidecar container:
DD_SERVICE: A name for your service. For example, gcr-sidecar-test.
DD_ENV: A name for your environment. For example, dev.
DD_SERVERLESS_LOG_PATH: Your log path. For example, /shared-volume/logs/*.log. The path must begin with the mount path you defined in the previous step.
FUNCTION_TARGET: The entry point of your function. For example, Main.
For a list of all environment variables, including additional tags, see Environment variables.
Set up logs.
In the previous step, you created a shared volume. You may have also set the DD_SERVERLESS_LOG_PATH environment variable, which defaults to /shared-volume/logs/app.log.
In this step, configure your logging library to write logs to the file set in DD_SERVERLESS_LOG_PATH. In .NET, Datadog recommends writing logs in JSON format. For example, you can use a third-party logging library such as Serilog:
usingSerilog;conststringLOG_FILE="/shared-volume/logs/app.log";builder.Host.UseSerilog((context,config)=>{// Ensure the directory existsDirectory.CreateDirectory(Path.GetDirectoryName(LOG_FILE)!);config.WriteTo.Console(newSerilog.Formatting.Json.JsonFormatter(renderMessage:true)).WriteTo.File(newSerilog.Formatting.Json.JsonFormatter(renderMessage:true),LOG_FILE);});logger.LogInformation("Hello World!");
Datadog recommends setting the environment variables DD_LOGS_INJECTION=true (in your main container) and DD_SOURCE=csharp (in your sidecar container) to enable advanced Datadog log parsing.
Unless specified otherwise, all environment variables below should be set in the sidecar container. Only environment variables used to configure the tracer should be set in your main application container.
The path where the sidecar should tail logs from. Defaults to /shared-volume/logs/app.log.
DD_LOGS_INJECTION
When true, enrich all logs with trace data for supported loggers. See Correlate Logs and Traces for more information. Set in your main application container, not the sidecar container.
Set the log source to enable a Log Pipeline for advanced parsing. To automatically apply language-specific parsing rules, set to csharp, or use your custom pipeline. Defaults to cloudrun.
DD_TAGS
Add custom tags to your logs, metrics, and traces. Tags should be comma separated in key/value format (for example: key1:value1,key2:value2).
FUNCTION_TARGET
Required for correct tagging. The entry point of your function. For example, Main. You can also find FUNCTION_TARGET on the source tab inside Google console: Function entry point.
Troubleshooting
This integration depends on your runtime having a full SSL implementation. If you are using a slim image, you may need to add the following command to your Dockerfile to include certificates:
RUN apt-get update && apt-get install -y ca-certificates
To have your Cloud Run services appear in the software catalog, you must set the DD_SERVICE, DD_VERSION, and DD_ENV environment variables.