/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.apm_bundle_jsonpfunction=window.apm_bundle_jsonpfunction||[]).push([[7],{1026:function(e,t,n){"use strict";n.r(t);var a=n(17),r=n(0),i=n(1),o=n.n(i),s=n(40),l=n.n(s),c=n(206);const p=r.i18n.translate("xpack.apm.tutorial.agent_config.defaultStandaloneConfig",{defaultMessage:"Default Standalone configuration"});var m=n(9);function u({options:e,selectedOption:t,onChange:n,fleetLink:i}){const{fleetAgents:s,standalone:l}=Object(m.groupBy)(e,"type"),c=(null==l?void 0:l.map((({key:e,label:t})=>({key:e,label:t}))))||[],p=null!=s&&s.length?[{key:"fleet_policies",label:r.i18n.translate("xpack.apm.tutorial.agent_config.fleetPoliciesLabel",{defaultMessage:"Fleet policies"}),options:s.map((({key:e,label:t})=>({key:e,label:t})))}]:[];return o.a.createElement(a.EuiFormRow,{label:r.i18n.translate("xpack.apm.tutorial.agent_config.choosePolicyLabel",{defaultMessage:"Choose policy"}),labelAppend:i&&o.a.createElement(a.EuiText,{size:"xs"},o.a.createElement(a.EuiLink,{"data-test-subj":"apmPolicySelectorLink",href:i.href},i.label)),helpText:r.i18n.translate("xpack.apm.tutorial.agent_config.choosePolicy.helper",{defaultMessage:"Adds the selected policy configuration to the snippet below."})},o.a.createElement(a.EuiComboBox,{"data-test-subj":`policySelector_${null==t?void 0:t.key}`,isClearable:!1,singleSelection:{asPlainText:!0},options:[...c,...p],selectedOptions:t?[{key:t.key,label:t.label}]:[],onChange:t=>{const a=e.find((({key:e})=>e===t[0].key));n(a)}}))}const d=l.a.div.withConfig({displayName:"CentralizedContainer",componentId:"sc-e43dnk-0"})(["display:flex;justify-content:center;align-items:center;"]),f=r.i18n.translate("xpack.apm.tutorial.agent_config.manageFleetPolicies",{defaultMessage:"Manage fleet policies"}),v=r.i18n.translate("xpack.apm.tutorial.agent_config.getStartedWithFleet",{defaultMessage:"Get started with fleet"}),g={fleetAgents:[],cloudStandaloneSetup:void 0,isFleetEnabled:!1};function h({isFleetEnabled:e,hasFleetAgents:t,basePath:n,kibanaVersion:a}){if(e)return t?{label:f,href:`${n}/app/fleet#/policies`}:{label:v,href:`${n}/app/integrations#/detail/apm/overview`}}t.default=function({variantId:e,http:t,basePath:n,isCloudEnabled:r,kibanaVersion:s}){const[l,m]=Object(i.useState)(g),[f,v]=Object(i.useState)(!0),[E,S]=Object(i.useState)();Object(i.useEffect)((()=>{!async function(){v(!0);try{const e=await t.get("/internal/apm/fleet/agents");e&&m(e)}catch(e){v(!1),console.error("Error while fetching fleet agents.",e)}}()}),[t]);const k=Object(i.useMemo)((()=>{const e=function({isCloudEnabled:e,data:t}){var n,a,r;const i=!(!e||null===(n=t.cloudStandaloneSetup)||void 0===n||!n.apmServerUrl),o=t.fleetAgents.map((e=>({key:e.id,type:"fleetAgents",label:e.name,apmServerUrl:e.apmServerUrl,secretToken:e.secretToken,isVisible:!0,isSelected:"policy-elastic-agent-on-cloud"===e.id}))),s=o.some((({isSelected:e})=>e));return[{key:"cloud",type:"standalone",label:p,apmServerUrl:null===(a=t.cloudStandaloneSetup)||void 0===a?void 0:a.apmServerUrl,secretToken:null===(r=t.cloudStandaloneSetup)||void 0===r?void 0:r.secretToken,isVisible:i&&!s,isSelected:!s},{key:"onPrem",type:"standalone",label:p,apmServerUrl:"http://localhost:8200",secretToken:"",isVisible:!i&&!s,isSelected:!s},...o].filter((({isVisible:e})=>e))}({isCloudEnabled:r,data:l}),t=e.find((({isSelected:e})=>e));return S(t),v(!1),e}),[l,r]);if(f)return o.a.createElement(d,{"data-test-subj":"loading"},o.a.createElement(a.EuiLoadingSpinner,null));const T=!!l.fleetAgents.length;return o.a.createElement(o.a.Fragment,null,o.a.createElement(u,{options:k,selectedOption:E,onChange:e=>S(e),fleetLink:h({isFleetEnabled:l.isFleetEnabled,hasFleetAgents:T,basePath:n,kibanaVersion:s})}),o.a.createElement(c.a,{variantId:e,apmServerUrl:null==E?void 0:E.apmServerUrl,secretToken:null==E?void 0:E.secretToken}))}},123:function(e,t,n){var a,r,i,o; /*! * mustache.js - Logic-less {{mustache}} templates with JavaScript * http://github.com/janl/mustache.js */o=function(e){var t=Object.prototype.toString,n=Array.isArray||function(e){return"[object Array]"===t.call(e)};function a(e){return"function"==typeof e}function r(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function i(e,t){return null!=e&&"object"==typeof e&&t in e}var o=RegExp.prototype.test,s=/\S/;var l={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},c=/\s*/,p=/\s+/,m=/\s*=/,u=/\s*\}/,d=/#|\^|\/|>|\{|&|=|!/;function f(e){this.string=e,this.tail=e,this.pos=0}function v(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function g(){this.cache={}}f.prototype.eos=function(){return""===this.tail},f.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},f.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},v.prototype.push=function(e){return new v(e,this)},v.prototype.lookup=function(e){var t,n=this.cache;if(n.hasOwnProperty(e))t=n[e];else{for(var r,o,s=this,l=!1;s;){if(e.indexOf(".")>0)for(t=s.view,r=e.split("."),o=0;null!=t&&o0?r[r.length-1][4]:n;break;default:a.push(t)}return n}(function(e){for(var t,n,a=[],r=0,i=e.length;r"===i?o=this.renderPartial(r,t,n,a):"&"===i?o=this.unescapedValue(r,t):"name"===i?o=this.escapedValue(r,t):"text"===i&&(o=this.rawValue(r)),void 0!==o&&(s+=o);return s},g.prototype.renderSection=function(e,t,r,i){var o=this,s="",l=t.lookup(e[1]);if(l){if(n(l))for(var c=0,p=l.length;c"'`=\/]/g,(function(e){return l[e]}))},e.Scanner=f,e.Context=v,e.Writer=g,e},t&&"string"!=typeof t.nodeName?o(t):(r=[t],void 0===(i="function"==typeof(a=o)?a.apply(t,r):a)||(e.exports=i))},206:function(e,t,n){"use strict";n.d(t,"a",(function(){return Z}));var a=n(1),r=n.n(a),i=n(17),o=n(0),s=n(37);function l({apmServerUrl:e,secretToken:t}){const n=[{setting:"OTEL_EXPORTER_OTLP_ENDPOINT",value:e||""},{setting:"OTEL_EXPORTER_OTLP_HEADERS",value:`"Authorization=Bearer ${t||""}"`},{setting:"OTEL_METRICS_EXPORTER",value:"otlp",notes:"Enable metrics when supported by your OpenTelemetry client."},{setting:"OTEL_LOGS_EXPORTER",value:"otlp",notes:"Enable logs when supported by your OpenTelemetry client"},{setting:"OTEL_RESOURCE_ATTRIBUTES",value:"service.name=,service.version=,deployment.environment=production"}],a=[{field:"setting",width:"23%",name:o.i18n.translate("xpack.apm.tutorial.config_otel.column.configSettings",{defaultMessage:"Configuration setting (1)"})},{field:"value",width:"55%",name:o.i18n.translate("xpack.apm.tutorial.config_otel.column.configValue",{defaultMessage:"Configuration value"}),render:(e,{value:t})=>r.a.createElement(r.a.Fragment,null,r.a.createElement(i.EuiText,{size:"s",color:"accent"},t),t&&r.a.createElement(i.EuiButtonIcon,{"aria-label":o.i18n.translate("xpack.apm.tutorial.config_otel.column.value.copyIconText",{defaultMessage:"Copy to clipboard"}),color:"text",iconType:"copy",onClick:()=>Object(i.copyToClipboard)(t)}))},{field:"notes",name:o.i18n.translate("xpack.apm.tutorial.config_otel.column.notes",{defaultMessage:"Notes"})}];return r.a.createElement(r.a.Fragment,null,r.a.createElement(i.EuiBasicTable,{items:n,columns:a,"data-test-subj":"otel-instructions-table"}),r.a.createElement(i.EuiSpacer,{size:"m"}),r.a.createElement(i.EuiText,{size:"xs",color:"subdued"},r.a.createElement(s.FormattedMessage,{id:"xpack.apm.tutorial.config_otel.description1",defaultMessage:"(1) OpenTelemetry agents and SDKs must support the {otelExporterOtlpEndpoint}, {otelExporterOtlpHeaders}, and {otelResourceAttributes} variables; some unstable components may not yet comply with this requirement.",values:{otelExporterOtlpEndpoint:r.a.createElement(i.EuiLink,{"data-test-subj":"apmOpenTelemetryInstructionsOtelExporterOtlpEndpointLink",target:"_blank",href:"https://github.com/open-telemetry/opentelemetry-specification/blob/v1.10.0/specification/protocol/exporter.md"},"OTEL_EXPORTER_OTLP_ENDPOINT"),otelExporterOtlpHeaders:r.a.createElement(i.EuiLink,{"data-test-subj":"apmOpenTelemetryInstructionsOtelExporterOtlpHeadersLink",target:"_blank",href:"https://github.com/open-telemetry/opentelemetry-specification/blob/v1.10.0/specification/protocol/exporter.md"},"OTEL_EXPORTER_OTLP_HEADERS"),otelResourceAttributes:r.a.createElement(i.EuiLink,{"data-test-subj":"apmOpenTelemetryInstructionsOtelResourceAttributesLink",target:"_blank",href:"https://github.com/open-telemetry/opentelemetry-specification/blob/v1.10.0/specification/resource/sdk.md"},"OTEL_RESOURCE_ATTRIBUTES")}}),r.a.createElement(i.EuiSpacer,{size:"xs"}),r.a.createElement(s.FormattedMessage,{id:"xpack.apm.tutorial.config_otel.description2",defaultMessage:"The 'OTEL_METRICS_EXPORTER` and 'OTEL_LOGS_EXPORTER' environment variables may not be supported by some SDKs."}),r.a.createElement(i.EuiSpacer,{size:"xs"}),r.a.createElement(s.FormattedMessage,{id:"xpack.apm.tutorial.config_otel.description3",defaultMessage:"The exhaustive list of environment variables, command line parameters, and configuration code snippets (according to the OpenTelemetry specification) is available in the {otelInstrumentationGuide}. Some unstable OpenTelemetry clients may not support all features and may require alternate configuration mechanisms.",values:{otelInstrumentationGuide:r.a.createElement(i.EuiLink,{"data-test-subj":"apmOpenTelemetryInstructionsOpenTelemetryInstrumentationGuideLink",target:"_blank",href:"https://opentelemetry.io/docs/instrumentation"},o.i18n.translate("xpack.apm.tutorial.config_otel.instrumentationGuide",{defaultMessage:"OpenTelemetry Instrumentation guide"}))}})))}var c=n(123),p=n.n(c);const m=o.i18n.translate("xpack.apm.tutorial.shared_clients.configure.commands.serviceNameHint",{defaultMessage:"The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space."}),u=o.i18n.translate("xpack.apm.tutorial.shared_clients.configure.commands.secretTokenHint",{defaultMessage:"Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server."}),d=o.i18n.translate("xpack.apm.tutorial.shared_clients.configure.commands.serverUrlHint",{defaultMessage:"Set the custom APM Server URL (default: {defaultApmServerUrl}). The URL must be fully qualified, including protocol (http or https) and port.",values:{defaultApmServerUrl:"http://localhost:8200"}}),f=o.i18n.translate("xpack.apm.tutorial.shared_clients.configure.commands.serviceEnvironmentHint",{defaultMessage:'The name of the environment this service is deployed in, e.g., "production" or "staging". Environments allow you to easily filter data on a global level in the APM UI. It\'s important to be consistent when naming environments across agents.'}),v={apmServiceName:"Delastic.apm.service_name",secretToken:"Delastic.apm.secret_token",apmServerUrl:"Delastic.apm.server_url",apmEnvironment:"Delastic.apm.environment"},g={start:1,highlight:"",annotations:{2:m,3:u,4:d,5:f}},h=`java -javaagent:/path/to/elastic-apm-agent-.jar \\\n-${v.apmServiceName}={{{apmServiceName}}} \\\n-${v.secretToken}={{{secretToken}}} \\\n-${v.apmServerUrl}={{{apmServerUrl}}} \\\n-${v.apmEnvironment}={{{apmEnvironment}}} \\\n-Delastic.apm.application_packages=org.example \\\n-jar {{{apmServiceName}}}.jar`,E={apmServiceName:"serviceName",secretToken:"secretToken",apmServerUrl:"serverUrl",apmEnvironment:"environment"},S={start:1,highlight:"3, 5, 7, 9",annotations:{3:`${m} ${o.i18n.translate("xpack.apm.tutorial.nodeClient.createConfig.commands.serviceName",{defaultMessage:"Overrides the service name in package.json."})}`,5:u,7:d,9:f}},k=`// ${o.i18n.translate("xpack.apm.tutorial.nodeClient.configure.commands.addThisToTheFileTopComment",{defaultMessage:"Add this to the very top of the first file loaded in your app"})}\nvar apm = require('elastic-apm-node').start({\n ${E.apmServiceName}: '{{{apmServiceName}}}',\n\n ${E.secretToken}: '{{{secretToken}}}',\n\n ${E.apmServerUrl}: '{{{apmServerUrl}}}',\n\n ${E.apmEnvironment}: '{{{apmEnvironment}}}'\n})`,T={apmServiceName:"SERVICE_NAME",secretToken:"SECRET_TOKEN",apmServerUrl:"SERVER_URL",apmEnvironment:"ENVIRONMENT"},b={start:1,highlight:"1-4, 7, 9, 11, 13, 16-19",annotations:{2:o.i18n.translate("xpack.apm.tutorial.djangoClient.configure.commands.addAgentComment",{defaultMessage:"Add the agent to installed apps"}),7:m,9:u,11:d,13:f,17:o.i18n.translate("xpack.apm.tutorial.djangoClient.configure.commands.addTracingMiddlewareComment",{defaultMessage:"Add our tracing middleware to send performance metrics"})}},y=`INSTALLED_APPS = (\n 'elasticapm.contrib.django',\n # ...\n)\n\nELASTIC_APM = {\n '${T.apmServiceName}': '{{{apmServiceName}}}',\n\n '${T.secretToken}': '{{{secretToken}}}',\n\n '${T.apmServerUrl}': '{{{apmServerUrl}}}',\n\n '${T.apmEnvironment}': '{{{apmEnvironment}}}',\n}\n\nMIDDLEWARE = (\n 'elasticapm.contrib.django.middleware.TracingMiddleware',\n #...\n)`,_={apmServiceName:"SERVICE_NAME",secretToken:"SECRET_TOKEN",apmServerUrl:"SERVER_URL",apmEnvironment:"ENVIRONMENT"},x={start:1,highlight:"2-4, 7-18",annotations:{9:m,11:u,13:d,15:f}},U=`# ${o.i18n.translate("xpack.apm.tutorial.flaskClient.configure.commands.initializeUsingEnvironmentVariablesComment",{defaultMessage:"Initialize using environment variables"})}\nfrom elasticapm.contrib.flask import ElasticAPM\napp = Flask(__name__)\napm = ElasticAPM(app)\n\n# ${o.i18n.translate("xpack.apm.tutorial.flaskClient.configure.commands.configureElasticApmComment",{defaultMessage:"Or use ELASTIC_APM in your application's settings"})}\nfrom elasticapm.contrib.flask import ElasticAPM\napp.config['ELASTIC_APM'] = {\n '${_.apmServiceName}': '{{{apmServiceName}}}',\n\n '${_.secretToken}': '{{{secretToken}}}',\n\n '${_.apmServerUrl}': '{{{apmServerUrl}}}',\n\n '${_.apmEnvironment}': '{{{apmEnvironment}}}',\n}\n\napm = ElasticAPM(app)`,O={apmServiceName:"service_name",secretToken:"secret_token",apmServerUrl:"server_url",apmEnvironment:"environment"},C={start:1,highlight:"3, 5, 7, 9",annotations:{3:`${m} ${o.i18n.translate("xpack.apm.tutorial.railsClient.createConfig.commands.defaultServiceName",{defaultMessage:"Defaults to the name of your Rails app."})}`,5:u,7:d,9:f}},N=`# config/elastic_apm.yml:\n\n${O.apmServiceName}: '{{{apmServiceName}}}'\n\n${O.secretToken}: '{{{secretToken}}}'\n\n${O.apmServerUrl}: '{{{apmServerUrl}}}'\n\n${O.apmEnvironment}: '{{{apmEnvironment}}}'`,A={apmServiceName:"service_name",secretToken:"secret_token",apmServerUrl:"server_url",apmEnvironment:"environment"},M={start:1,highlight:"3, 5, 7, 9",annotations:{3:`${m} ${o.i18n.translate("xpack.apm.tutorial.rackClient.createConfig.commands.defaultsToTheNameOfRackAppClassComment",{defaultMessage:"Defaults to the name of your Rack app's class."})}`,5:u,7:d,9:f}},w=`# config/elastic_apm.yml:\n\n${A.apmServiceName}: '{{{apmServiceName}}}'\n\n${A.secretToken}: '{{{secretToken}}}'\n\n${A.apmServerUrl}: '{{{apmServerUrl}}}',\n\n${A.apmEnvironment}: '{{{apmEnvironment}}}'`,$={apmServiceName:"ELASTIC_APM_SERVICE_NAME",secretToken:"ELASTIC_APM_SECRET_TOKEN",apmServerUrl:"ELASTIC_APM_SERVER_URL",apmEnvironment:"ELASTIC_APM_ENVIRONMENT"},R={start:1,highlight:"2, 4, 6, 8",annotations:{2:`${m} ${o.i18n.translate("xpack.apm.tutorial.goClient.configure.commands.usedExecutableNameComment",{defaultMessage:"If not specified, the executable name will be used."})}`,4:u,6:d,8:f}},j=`# ${o.i18n.translate("xpack.apm.tutorial.goClient.configure.commands.initializeUsingEnvironmentVariablesComment",{defaultMessage:"Initialize using environment variables:"})}\nexport ${$.apmServiceName}={{{apmServiceName}}}\n\nexport ${$.secretToken}={{{secretToken}}}\n\nexport ${$.apmServerUrl}={{{apmServerUrl}}}\n\nexport ${$.apmEnvironment}={{{apmEnvironment}}}\n`,I={apmServiceName:"ServiceName",secretToken:"SecretToken",apmServerUrl:"ServerUrl",apmEnvironment:"Environment"},L={start:1,highlight:"3, 4, 5, 6",annotations:{3:`${m} ${o.i18n.translate("xpack.apm.tutorial.dotnetClient.createConfig.commands.defaultServiceName",{defaultMessage:"Default is the entry assembly of the application."})}`,4:u,5:d,6:f}},P=`{\n "ElasticApm": {\n "${I.apmServiceName}": "{{{apmServiceName}}}",\n "${I.secretToken}": "{{{secretToken}}}",\n "${I.apmServerUrl}": "{{{apmServerUrl}}}",\n "${I.apmEnvironment}": "{{{apmEnvironment}}}",\n }\n}`,V={apmServiceName:"elastic_apm.service_name",secretToken:"elastic_apm.secret_token",apmServerUrl:"elastic_apm.server_url",apmEnvironment:"elastic_apm.environment"},D={start:1,highlight:"1, 3, 5, 7",annotations:{1:m,3:u,5:d,7:f}},F=`${V.apmServiceName}="{{{apmServiceName}}}"\n\n${V.secretToken}="{{{secretToken}}}"\n\n${V.apmServerUrl}="{{{apmServerUrl}}}"\n\n${V.apmEnvironment}="{{{apmEnvironment}}}"`,z={apmServiceName:"serviceName",apmServerUrl:"serverUrl",apmServiceVersion:"serviceVersion",apmEnvironment:"environment"},B=o.i18n.translate("xpack.apm.tutorial.jsClient.installDependency.commands.setServiceVersionComment",{defaultMessage:"Set the service version (required for source map feature)"}),H={java:h,node:k,django:y,flask:U,rails:N,rack:w,go:j,dotnet:P,php:F,js:`import { init as initApm } from '@elastic/apm-rum'\nvar apm = initApm({\n ${z.apmServiceName}: '{{{apmServiceName}}}',\n\n ${z.apmServerUrl}: '{{{apmServerUrl}}}',\n\n serviceVersion: '',\n\n ${z.apmEnvironment}: '{{{apmEnvironment}}}'\n})`,js_script:`