---
title: Code block
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > Cdocs e2e tests > Code block
---

# Code block

## Overview{% #overview %}

This page contains examples of the code block component.

## Examples{% #examples %}

### Basic code block{% #basic-code-block %}

In the `example.js` file:

```
const greeting = "Hello, world!";
console.log(greeting);
```

### Collapsible{% #collapsible %}

In the `long_script.py` file:

```
import requests

def fetch_metrics(api_key, app_key):
    url = "https://api.datadoghq.com/api/v1/metrics"
    headers = {
        "DD-API-KEY": api_key,
        "DD-APPLICATION-KEY": app_key,
    }
    response = requests.get(url, headers=headers)
    return response.json()

if __name__ == "__main__":
    data = fetch_metrics("YOUR_API_KEY", "YOUR_APP_KEY")
    print(data)
```

### Copy disabled{% #copy-disabled %}

In the `dangerous_command.sh` file:

```
# This command is shown for reference only
dd-agent stop && rm -rf /etc/datadog-agent && dd-agent start
```

### Wrap enabled{% #wrap-enabled %}

In the `log_output.txt` file:

```
2024-01-15T10:30:45.123Z [INFO] datadog.agent - Successfully connected to the Datadog intake endpoint at https://agent-intake.logs.datadoghq.com:443 with API key ending in ...abcd
```

### All options combined{% #all-options-combined %}

In the `datadog.yaml` file:

```
api_key: YOUR_API_KEY
site: datadoghq.com
logs_enabled: true
logs_config:
  container_collect_all: true
  auto_multi_line_detection: true
process_config:
  process_collection:
    enabled: true
```

### Multiple languages{% #multiple-languages %}

In the `main.go` file:

```
package main

import (
    "fmt"
    "github.com/DataDog/datadog-go/statsd"
)

func main() {
    client, err := statsd.New("127.0.0.1:8125")
    if err != nil {
        fmt.Println(err)
        return
    }
    client.Gauge("example.gauge", 42, nil, 1)
}
```

In the `example.rb` file:

```
require 'datadog/statsd'

statsd = Datadog::Statsd.new('localhost', 8125)
statsd.increment('example.counter')
statsd.gauge('example.gauge', 42)
```
